package com.ha7419x.service.fallback;

import com.ha7419x.service.IDeptClientService;
import com.ha7419x.vo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class IDeptClientServiceFallbackFactory implements FallbackFactory<IDeptClientService>{

    @Override
    public IDeptClientService create(Throwable throwable) {
        return new IDeptClientService() {
            @Override
            public Dept get(Long id) {
                Dept dept = new Dept();
                dept.setDeptNo("9999");
                dept.setDeptName("【ERROR】demo-service feign");
                dept.setLoc("【ERROR】demo-service feign");
                return dept;
            }

            @Override
            public List<Dept> list() {
                return null;
            }

            @Override
            public boolean add(Dept dept) {
                return false;
            }
        };
    }
}

